package page111;

public class Main {
    public static void main(String[] args){
        Rational r1=new Rational();
        Rational r2=new Rational();
        r1.setNumeratorAndDenominator(-2,-4);
        r2.setNumeratorAndDenominator(-9,-3);
        System.out.println(r1.getNumerator()+"/"+r1.getDenominator());
        System.out.println(r2.getNumerator()+"/"+r2.getDenominator());

        System.out.println(r1.add(r2).getNumerator()+"/"+r1.add(r2).getDenominator());
        System.out.println(r1.sub(r2).getNumerator()+"/"+r1.sub(r2).getDenominator());
        System.out.println(r1.muti(r2).getNumerator()+"/"+r1.muti(r2).getDenominator());
        System.out.println(r1.div(r2).getNumerator()+"/"+r1.div(r2).getDenominator());
//        计算2/1+3/2+5/3+8/5+13/8+...前十项的和
//        Rational r1=new Rational();
//        Rational r2=new Rational();
//        int i,p1=1,p2=2;
//        r1.setNumeratorAndDenominator(p2,p1);
//        for(i=1;i<10;i++){
//            r2.setNumeratorAndDenominator(p2+=p1,p1=p2-p1);
//            r1=r1.add(r2);
//        }
//        System.out.println(r1.getNumerator()+"/"+r1.getDenominator());

    }
}
